/*
 * MyTableCellRenderer.java
 *
 * Created on 12. Juni 2007, 21:32
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package DieSiedler;

import java.awt.Color;
import java.awt.Component;
import java.util.HashMap;
import javax.swing.JTable;
import javax.swing.table.TableCellRenderer;

/**
 *
 * @author mannholi
 */

/**
 * Rendert Tabellenfarben in der ServerGraphicalOverviw Spieler-Anzeige-Tabelle
 */
class MyTableCellRenderer extends javax.swing.table.DefaultTableCellRenderer
{
        private HashMap<Integer,Color> colors;
        public MyTableCellRenderer(){
         
            this.colors=new HashMap<Integer,Color>();
                    
        }
        public Component getTableCellRendererComponent(JTable table, Object value,boolean isSelected,boolean hasFocus,int row,int column) {
            Component component = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
            if(colors.containsKey(row)){
                component.setBackground(colors.get(row));
            }
            return component;
        }

    public void add(int row, Color color) {
        colors.put(row,color);
    }
}

